package org.groupg.filetodb.model.finals;

import org.groupg.filetodb.model.TableRunning;

import java.time.LocalDateTime;

public enum TableRunningStatus {
    READY {
        @Override
        public void changeStatus(TableRunning tableRunning) {
            tableRunning.getInterval().clear();
        }
    }, RUNNING {
        @Override
        public void changeStatus(TableRunning tableRunning) {
            tableRunning.setStartTime(LocalDateTime.now());
            tableRunning.getInterval().start();
        }
    }, FINISHED {
        @Override
        public void changeStatus(TableRunning tableRunning) {
            tableRunning.setEndTime(LocalDateTime.now());
            tableRunning.setDuration(tableRunning.getInterval().interval());
        }
    }, ERROR {
        @Override
        public void changeStatus(TableRunning tableRunning) {
            tableRunning.setEndTime(LocalDateTime.now());
            tableRunning.setDuration(tableRunning.getInterval().interval());
        }
    };

    abstract public void changeStatus(TableRunning tableRunning);
}
